{% extends 'xhs/layout.html' %}

{% block title %}笔记类型统计 - 小红书数据管理系统{% endblock %}

{% block page_title %}笔记类型统计{% endblock %}

{% block content %}
<div class="row">
    <div class="col-12">
        <div class="card mb-4">
            <div class="card-header">
                <h5 class="card-title mb-0"><i class="fas fa-tags text-danger"></i> 所有笔记类型</h5>
                <p class="text-muted small mb-0">共{{ types|length }}种类型</p>
            </div>
            <div class="card-body">
                {% if types %}
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>类型名称</th>
                                    <th>笔记数量</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for type in types %}
                                <tr>
                                    <td>{{ loop.index }}</td>
                                    <td>{{ type.keyword }}</td>
                                    <td><span class="badge badge-primary">{{ type.count }}</span></td>
                                    <td>
                                        <a href="/notes?keyword={{ type.keyword }}" class="btn btn-sm btn-outline-primary">
                                            查看所有
                                        </a>
                                    </td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                {% else %}
                    <p class="text-muted">暂无笔记类型数据</p>
                {% endif %}
            </div>
        </div>
    </div>
</div>

<div class="row">
    {% for type in types %}
        <div class="col-md-6 mb-4">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0"><i class="fas fa-tag text-danger"></i> {{ type.keyword }}</h5>
                    <p class="text-muted small mb-0">共{{ type.count }}篇笔记</p>
                </div>
                <div class="card-body">
                    {% if type.examples %}
                        <h6 class="card-subtitle mb-3 text-muted">示例笔记</h6>
                        <ul class="list-group">
                            {% for note in type.examples %}
                                <li class="list-group-item">
                                    <div class="d-flex justify-content-between align-items-center">
                                        <div>
                                            <a href="/notes/{{ note.id }}" class="font-weight-bold">{{ note.title }}</a>
                                            <p class="text-muted small mb-0">作者: {{ note.author }}</p>
                                        </div>
                                        <div>
                                            <span class="badge badge-danger mr-1">
                                                <i class="fas fa-heart"></i> {{ note.likes }}
                                            </span>
                                            <span class="badge badge-info">
                                                <i class="fas fa-comment"></i> {{ note.comments }}
                                            </span>
                                        </div>
                                    </div>
                                </li>
                            {% endfor %}
                        </ul>
                        <div class="mt-3">
                            <a href="/notes?keyword={{ type.keyword }}" class="btn btn-sm btn-outline-primary">
                                查看该类型所有笔记
                            </a>
                        </div>
                    {% else %}
                        <p class="text-muted">暂无示例笔记</p>
                    {% endif %}
                </div>
            </div>
        </div>
    {% endfor %}
</div>
{% endblock %}

{% block scripts %}
<script>
    $(document).ready(function() {
        // 设置当前导航项为活动状态
        $('.nav-link').removeClass('active');
        $('.nav-link[href="/note-types"]').addClass('active');
    });
</script>
{% endblock %} 